<template>
	<view class="merchInfo">
		<comHead :title="$t('index.ddxq')" :isLeft="true" :isRight="false"></comHead>
		<view class="address">
			<view class="l">
				<image src="https://siha.vxmeng.com/static/my/dw.png" mode="widthFix"></image>
			</view>
			<view class="c">
				<text>{{merchInfo.address_username}}</text>
				<text>{{merchInfo.address_mobile}}</text>
				<view class="">{{merchInfo.address_detail}}</view>
			</view>
			<!-- <view @click="editAddress" class="r" v-if="merchInfo.state != 4">修改</view> -->
			<!-- <view class="r-2">
				<image src="https://siha.vxmeng.com/static/index/kd.png" mode="widthFix"></image>
				<text>已签收</text>
			</view> -->
		</view>
		<view class="item">
			<view class="top">
				<text>{{$t('index.zpdhsj')}}:{{merchInfo.create_time}}</text>
				<text style="text-align: center;">{{merchInfo.status==1?$t('index.dfh'):merchInfo.status==2?$t('index.yfh'):$t('index.ysh')}}</text>
			</view>
			<view class="c">
				<view class="imageBox">
					<image src="https://siha.vxmeng.com/static/index/gift-img.png" mode="widthFix"></image>
					<image :src="getImg(merchInfo.image)" mode="widthFix"></image>
				</view>
				<view class="info">
					<text class="name">{{merchInfo.name}}</text>
					<view class="blurb">{{merchInfo.blurb}}</view>
					<view class="price">
						<image :src="getImg('/static/index/dou.png')" mode="widthFix"></image>
						{{merchInfo.money}}
					</view>
				</view>
			</view>
			<view class="bot">
				<view class="btn" @click="comLink('/pages/my/help')">{{$t('index.kffw')}}</view>
				<view v-if="merchInfo.state != 4" class="btn" @click="openPop(merchInfo)">{{$t('index.qrsh')}}</view>
				<view v-else class="btn" style="color:#767B82">{{$t('index.jywc')}}</view>
			</view>
		</view>
		
		<view class="tips">
			<view class="tit">{{$t('index.zpts')}}</view>
			<view class="tip">1.{{$t('index.cgdhdzp')}}</view>
			<view class="tip">2.{{$t('index.dhdzpbhbt')}}</view>
		</view>
		
		<view class="other">
			<view class="ID">
				<text>{{$t('index.ddbh')}}：{{merchInfo.order_no}}</text>
				<view @click="onCopy(merchInfo.order_no)" class="copy">{{$t('index.fz')}}</view>
			</view>
			<text>{{$t('index.dhsj')}}：{{merchInfo.create_time}}</text>
			<template v-if="merchInfo.status!=1">
				<text>{{$t('index.wlkd')}}：{{merchInfo.express_company}}</text>
				<view class="ID">
					<text>{{$t('index.kddh')}}：{{merchInfo.express_no}}</text>
					<view @click="onCopy(merchInfo.express_no)" class="copy">{{$t('index.fz')}}</view>
				</view>
				<text>{{$t('index.fhsj')}}：{{merchInfo.fa_time}}</text>
				<text v-if="merchInfo.status == 3">{{$t('index.qssj')}}：{{merchInfo.shou_time}}</text>
			</template>
		</view>
		
		<view class="giftPop" v-if="isHarvest">
			<view class="box">
				<view class="imgs">
					<image src="https://siha.vxmeng.com/static/index/gift-img.png" mode="widthFix"></image>
					<image :src="getImg(currentPeriphery.image)" mode="widthFix"></image>
				</view>
				<view class="info">
					<text class="name">{{$t('index.qrsdhlm')}}</text>
					<text class="intro">{{$t('index.qrshhcdd')}}</text>
					<view class="btns">
						<view class="f" @click="isHarvest=false">{{$t('index.qx')}}</view>
						<view class="t" @click="comfirm()">{{$t('index.qrsh')}}</view>
					</view>
				</view>
				<image class="close" @click="isHarvest = false" src="https://siha.vxmeng.com/static/index/close.png" mode="widthFix"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isHarvest: false,
				merchInfo:{},
				user_order_id:''
			}
		},
		onLoad(options) {
			this.user_order_id = options.id
			this.getUserOrderDetail()
		},
		methods: {
			async getUserOrderDetail(){
				const res = await this.$myRequest({
					url: 'api/order/getUserOrderDetail',
					data: {
						user_order_id:this.user_order_id
					}
				})
				if (res.code == 1) {
					this.merchInfo = res.data
				}
			},
			openPop(item){
				this.currentPeriphery = item
				this.isHarvest = true
			},
			editAddress(){
				this.comLink('/pages/my/addressManage')
			},
			onCopy(e){
			  uni.setClipboardData({
					data: e,
					success: () => {
						console.log('success');
						uni.showToast({
							title: this.$t('index.fzcg'),
							icon: 'success',
							duration: 2000
						});
					},
					fail:(error)=> {
						console.log('失败',error);
						uni.showToast({
							title: this.$t('index.fzsb'),
							icon: 'none'
						});
					}
			
				})
			},
			async comfirm(){
				const res = await this.$myRequest({
					url: 'api/order/editUserOrder',
					data: {
						user_order_id:this.merchInfo.id
					}
				})
				if (res.code == 1) {
					console.log(res)
					this.isHarvest = false
					this.$tools.showTx(this.$t('index.qrshcg'))
					this.getUserOrderDetail()
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.merchInfo{
		height: 100vh;
		overflow: auto;
		.address{
			height: 128rpx;
			background: linear-gradient(137deg, rgba(#222222, 0.65) 0%, rgba(30, 36, 44, 0.65) 100%);
			color: #fff;
			font-size: 28rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 30rpx;
			.l{
				display: flex;
				align-items: center;
				margin-right: 20rpx;
				image{
					width: 40rpx;
				}
			}
			.c{
				flex: 1;
				text{
					margin-right: 30rpx;
				}
			}
			.r{
				width: 100rpx;
				height: 60rpx;
				line-height: 56rpx;
				border: 2rpx solid #FFC41F;
				border-radius: 30rpx;
				text-align: center;
			}
			.r-2{
				width: 100rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				image{
					width: 40rpx;
					margin-bottom: 10rpx;
				}
				text{
					background: linear-gradient(270deg, #5F58FD 0%, #62B6FC 100%);
					-webkit-background-clip: text;
					-webkit-text-fill-color: transparent;
					background-clip: text;
					text-fill-color: transparent;
				}
			}
		}
		
		.item{
			height: 420rpx;
			border-radius: 30rpx;
			margin-top: 18rpx;
			color: #fff;
			background: linear-gradient(137deg, rgba(34, 34, 34, 0.65) 0%, rgba(30, 30, 30, 1) 100%);
			.top{
				padding: 0 30rpx;
				height: 98rpx;
				font-size: 28rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
			}
			.c{
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 40rpx 30rpx;
				height: 238rpx;
				.imageBox{
					width: 240rpx;
					height: 132rpx;
					border-radius: 20rpx;
					overflow: hidden;
					position: relative;
					display: flex;
					justify-content: center;
					align-items: center;
					image{
						width: 240rpx;
						position: absolute;
						&:last-child{
							width: 128rpx;
							// position: absolute;
							// top: 12rpx;
							// left: 30%;
						}
					}
				}
			}
			.info{
				flex: 1;
				padding: 0 10rpx;
				display: flex;
				height: 150rpx;
				flex-direction: column;
				justify-content: space-between;
				.blurb{
					width: 390rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					font-size: 24rpx;
				}
				image{
					width: 50rpx;
					position: static;
					vertical-align: middle;
				}
			}
			.bot{
				width: 100%;
				height: 84rpx;
				display: flex;
				border-top: 2rpx solid rgb(97,97,122);
				.btn{
					width: 50%;
					text-align: center;
					line-height: 84rpx;
					border-right: 2rpx solid rgb(97,97,122);
					&:last-child{
						border: none;
					}
				}
			}
		}
		
		.tips{
			background: linear-gradient(137deg, rgba(#222222, 0.65) 0%, rgba(30, 36, 44, 0.65) 100%);
			padding: 20rpx 30rpx;
			display: flex;
			flex-direction: column;
			margin-top: 18rpx;
			color: #fff;
			.tit{
				font-size: 28rpx;
				margin-bottom: 10rpx;
			}
			.tip{
				font-size: 24rpx;
				line-height: 36rpx;
			}
		}
		
		.other{
			background: linear-gradient(137deg, rgba(#222222, 0.65) 0%, rgba(30, 36, 44, 0.65) 100%);
			padding: 30rpx;
			display: flex;
			flex-direction: column;
			margin-top: 18rpx;
			color: #767B82;
			font-size: 28rpx;
			.ID{
				display: flex;
				justify-content: space-between;
				align-items: center;
				.copy{
					width: 80rpx;
					height: 40rpx;
					font-size: 20rpx;
					color: #fff;
					text-align: center;
					line-height: 36rpx;
					border: 2rpx solid #767B82;
					border-radius: 20rpx;
				}
			}
		}
		
		.giftPop{
			position: fixed;
			width: 100vw;
			height: 100vh;
			top: 0;
			left: 0;
			z-index: 102;
			color: #fff;
			background-color: rgba(0, 0, 0, .6);
			.box{
				width: 570rpx;
				height: 720rpx;
				position: absolute;
				top: 50%;
				left: 50%;
				transform: translate(-50%, -50%);
				.imgs{
					position: relative;
					font-size: 0;
					image{
						&:first-child{
							width: 100%;
						}
						&:last-child{
							width: 300rpx;
							position: absolute;
							top: 20rpx;
							left: 160rpx;
						}
					}
				}
				.info{
					display: flex;
					flex-direction: column;
					align-items: center;
					height: 312rpx;
					border-radius: 0 0 24rpx 24rpx;
					background: linear-gradient(137deg, rgb(28,60,122) 14%, rgb(86,8,102) 87%);
					.name{
						font-size: 30rpx;
						margin-top: 30rpx;
					}
					.intro{
						font-size: 26rpx;
						margin-top: 20rpx;
					}
					.price{
						width: 180rpx;
						height: 60rpx;
						background: #7973D7;
						margin-top: 30rpx;
						font-size: 20rpx;
						display: flex;
						justify-content: center;
						align-items: center;
						border-radius: 20rpx;
						overflow: hidden;
						position: relative;
						image{
							width: 20rpx;
							margin-right: 20rpx;
						}
						text{
							&:last-child{
								font-size: 16rpx;
								position: absolute;
								top: 0;
								right: 0;
								background: linear-gradient(109deg, rgba(48, 126, 254, 0.7569) 19%, #D614FF 83%);
								width: 80rpx;
								height: 20rpx;
								line-height: 20rpx;
							}
						}
					}
					.btns{
						display: flex;
						justify-content: center;
						height: 80rpx;
						margin-top: 50rpx;
						view{
							width: 250rpx;
							font-size: 30rpx;
							text-align: center;
							line-height: 80rpx;
							border-radius: 40rpx;
						}
						.f{
							margin-right: 20rpx;
							border: 2rpx solid #62B6FC;
						}
						.t{
							background: linear-gradient(285deg, #62B6FC 0%, #5F58FD 77%, #5F58FD 98%);
						}
					}
				}
			}
			.close{
				width: 50rpx;
				display: block;
				margin: 20rpx auto;
			}
		}
		
	}
</style>

